﻿"use strict";

function AJAXFactory($http, $q) {
    var get = function (url) {
        var deferred = $q.defer();
        $http({
            url: url,
            method: "GET"
        })
        .success(function (response) {
            deferred.resolve(response);
        })
        .error(function (response) {
            deferred.reject(response);
        })
        return deferred.promise;
    }
    // Send The todo to..
    var post = function (url, data) {
        var deferred = $q.defer();
        $http({
            url: url,
            method: "POST",
            data: data
        })
        .success(function (response) {
            deferred.resolve(response);
        })
        .error(function (response) {
            deferred.reject(response);
        })
        return deferred.promise;
    }

    return {
        get: get,
        post: post
    }
}

AJAXFactory.$inject = ["$http", "$q"];